import 'package:flutter/material.dart';

void main() {
  runApp(MainPage());
}
//第一个类 负责对外
class MainPage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return _MainPageState();
  }
}
//第二个类 内部类 负责管理数据 处理业务逻辑 并且渲染视图
class _MainPageState extends State<MainPage>{
  int count = 0;
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter 有状态组件',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter 头部区域组件'),
        ),
        body: Container(
          child: Row(
            children: [
              TextButton(
                onPressed: () => {
                  setState(() {
                    count--;
                  })
                },
                child: Text('减')),
              Text(count.toString()),
              TextButton(
                onPressed: () => {
                  setState(() {
                    count++;
                  })
                },
                child: Text('加')),
            ],
            // child:GestureDetector(
            //   onTap: () => print('点击了文本'),
            //   child: Text('Flutter 中部区域组件'),
            // )
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => print('点击了FAB'),
          child: Icon(Icons.add),
        ),  
        bottomNavigationBar:Container(
          height: 80,
          child:Center(
            child:Text('Flutter 底部区域组件'),
          )
        )
      ),
    );
  }
}